package com.xijia.wuyouwallet.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xijia.wuyouwallet.MyApp;
import com.xijia.wuyouwallet.R;
import com.xijia.wuyouwallet.base.BaseActivity;
import com.xijia.wuyouwallet.utils.MyActivityManager;
import com.xijia.wuyouwallet.utils.SharedpreferncesUtil;
import com.xijia.wuyouwallet.utils.UrlConfig;

/**
 * Created by Administrator on 2017/7/16 0016.
 */

public class SettingActivity extends BaseActivity implements View.OnClickListener{
    private ImageView setting_back;
    private RelativeLayout setting_psd,setting_clear,setting_aboutUs,setting_treaty;
    private TextView setting_exit;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        initView();
    }

    private void initView(){
        setting_back = (ImageView) findViewById(R.id.setting_back);
        setting_back.setOnClickListener(this);
        setting_psd = (RelativeLayout) findViewById(R.id.setting_psd);
        setting_psd.setOnClickListener(this);
        setting_clear = (RelativeLayout) findViewById(R.id.setting_clear);
        setting_clear.setOnClickListener(this);
        setting_aboutUs = (RelativeLayout) findViewById(R.id.setting_aboutUs);
        setting_aboutUs.setOnClickListener(this);
        setting_treaty = (RelativeLayout) findViewById(R.id.setting_treaty);
        setting_treaty.setOnClickListener(this);
        setting_exit = (TextView) findViewById(R.id.setting_exit);
        setting_exit.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Bundle bundle = null;
        switch (view.getId()){
            case R.id.setting_back:
                finish();
                /*MyDialog dialog = new MyDialog(SettingActivity.this, "确定退出系统");
                dialog.showDialog();*/
                break;
            case R.id.setting_psd:
                jumpToPage(ManagePsdActivity.class);
                break;
            case R.id.setting_clear:
                showToast("缓存清除成功");
                break;
            case R.id.setting_aboutUs:
                jumpToPage(AboutusActivity.class);
                break;
            case R.id.setting_treaty:
                bundle = new Bundle();
                bundle.putString("url", UrlConfig.SERVE_AGREEMENT_URL);
                jumpToPage(CommonWvActivity.class,bundle);
                break;
            case R.id.setting_exit:
                SharedpreferncesUtil.putBoolean("is_login", false, SettingActivity.this);
                MyApp.userData = null;
                finish();
                MyActivityManager.getInstance().exit();
                jumpToPage(LoginActivity.class);
                break;
        }
    }
}
